package com.franklin.ideaplugin.mybatisrunner.psi;

import cn.hutool.crypto.digest.DigestUtil;
import com.franklin.ideaplugin.api.utils.psi.PsiMethodUtils;
import com.franklin.ideaplugin.mybatisrunner.utils.MybatisSqlUtils;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.util.PsiTreeUtil;

/**
 * @author Ye Junhui
 * @since 2024/2/20
 */
public class MybatisPsiAnnotation extends MybatisPsiElement<PsiAnnotation> {

    public MybatisPsiAnnotation(PsiAnnotation psiElement) {
        super(psiElement);
        PsiMethod psiMethod = PsiTreeUtil.getParentOfType(psiElement, PsiMethod.class);
        this.key = PsiMethodUtils.getMethodQualifiedNameWithParameters(psiMethod);
    }

    @Override
    public String buildSqlScript() {
        return MybatisSqlUtils.resolveMybatisSqlScript(psiElement);
    }

}
